﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Remoting.Messaging;

namespace CMS.Core
{
    public class ContextFactory
    {
        // <summary>
        /// 获取当前线程的数据上下文
        /// </summary>
        /// <returns>数据上下文</returns>
        public static CMSContext CurrentContext()
        {
            CMSContext context = CallContext.GetData("CMSContext") as CMSContext;
            
            if(context == null)
            {
                context = new CMSContext();
                CallContext.SetData("CMSContext", context);
            }

            return context;
        }
    }
}
